<template>
  <div class="scroll" :style="{ height: high + 'px' }" ref="scroll">
    <div class="board">
      <div class="item" v-for="item in imgList" @click="showMv(item.id,item.artistName,item.name)">
        <img v-lazy="item.cover" alt="" />
      </div>
    </div>
    <van-dialog v-model="show" title="提示" show-cancel-button>
      已经到最后了,没有数据可以加载了
    </van-dialog>
  </div>
</template>

<script>
import BScroll from "better-scroll";
import Vue from "vue";
import { Dialog } from "vant";
Vue.use(Dialog);
export default {
  data() {
    return {
      bs: null,
      high: 500,
      count: 1,
      show: false,
    };
  },
  props: ["imgList", "getData"],
  created() {},
  mounted() {
    this.$nextTick(() => {
      this.high = document.documentElement.clientHeight - 94;
      this.bs = new BScroll(this.$refs["scroll"], {
        // 监听下滑事件
        pullUpLoad: true,
        pullDownRefresh: true,
        click: true,
      });
      this.bs.on("pullingUp", () => {
        this.count++;
        var limit = 20 * this.count;
        this.getData(limit);
        this.bs.finishPullDown();
        if (limit == 40) {
          this.show = true;
        }
      });
    });
  },
  beforeDestroy() {
    this.bus = null;
  },
  methods: {
    showMv(id,artistName,name) {
      this.$emit('getUrl',{id,artistName,name})
    },
  },
};
</script>

<style scoped lang="scss">
.board {
  margin-top: 10px;
  margin-bottom: 50px;
  box-sizing: border-box;
  display: flex;
  padding: 0 18px;
  padding-bottom: 50px;
  justify-content: space-between;
  flex-flow: row wrap;
}
.board .item {
  width: 150px;
  height: 150px;
  // line-height: 170px;
  margin-bottom: 10px;
  border-radius: 15px;
  overflow: hidden;
}
.board .item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/deep/ .van-dialog__content {
  text-align: center;
}
.scroll {
  overflow: hidden;
}
</style>
